DeepDiff Fails to Detect Timezone Changes in Arrays with ignore_order=True#517
Closed
3schwartz wants to merge 2 commits intoqlustered:devfrom
3schwartz:deepdiff-fails-to-detect-timezone-changes-in-arrays
Closed
DeepDiff Fails to Detect Timezone Changes in Arrays with ignore_order=True#5173schwartz wants to merge 2 commits intoqlustered:devfrom 3schwartz:deepdiff-fails-to-detect-timezone-changes-in-arrays
3schwartz wants to merge 2 commits intoqlustered:devfrom
3schwartz:deepdiff-fails-to-detect-timezone-changes-in-arrays
Conversation
Member
|
Hi @3schwartz |
seperman
reviewed
Feb 4, 2025
Member
seperman
left a comment
There was a problem hiding this comment.
Hi @3schwartz
We currently treat timezone naive datetime objects as UTC datetimes. That is independent from truncate_datetime.
This also made me realize that we should convert the datetimes that have explicit timezone to their respective datetimes in UTC instead of "replacing" the timezone.
I have copy pasted your test and am playing with that idea. I will keep you posted.
Member
|
@3schwartz Your PR made me realize we need to be more consistent with our timezone logic. I changed our logic to:
That has a conflict with what you wanted in your tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Solution proposal for issue #516
Description
The
deepdifflibrary is unable to detect timezone changes in datetimes within arrays.When
ignore_order=Trueand a datetime is present within an array,deepdiffuses an execution path that makes aDeepHash. Due to the implementation ofdatetime_normalize, all datetimes have their timezone set to UTC:https://github.com/seperman/deepdiff/blob/c7183695a8b2049e53cfabc48c7b5adb28e45185/deepdiff/helper.py#L627
This behavior causes issues in our use case, as we rely on deepdiff to detect changes in datetime objects, including changes to their timezones.
Changes
Indent logic which replaces timezone to only affect those which has set
truncate_datetime.Notes
Existing logic was added in commits